<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Complaint.Models.Dtos.Complaint>" %>

<%@ Import Namespace="System.IO" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <title>Complaint #<%= Model.ComplaintID%>:
        <%= Html.Encode(Model.Title) %></title>
    <meta name="description" content="complaint against <%= Html.Encode(Model.Organisation.Name) %>: <%= Html.Encode(Model.Title) %>, lodged on <%= Html.Encode(String.Format("{0:g}", Model.DateLodged)) %>." />
    <meta name="keywords" content="complaint,<%= Html.Encode(Model.Organisation.Name) %>,<%= Html.Encode(Model.Title) %>,details,comments" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript">
        var complaintId = <%= Model.ComplaintID %>;
    </script>

    <script src="../../Scripts/Complaint/Views.Complaint.Details.js" type="text/javascript"></script>

    <h2>
        Complaint #<%= Model.ComplaintID%>:
        <%= Html.Encode(Model.Title) %></h2>
    <fieldset>
        <legend>Details</legend>
        <div class="receiver">
            <b>Complainee:</b>
            <%= Html.ActionLink(Html.Encode(Model.Organisation.Name), "Details", "Organisation", new { id = Model.Organisation.OrganisationID }, new { })%>
        </div>
        <div class="ref">
            <b>Ref:</b>
            <%= Html.Encode(String.IsNullOrEmpty(Model.OrganisationRef) ? "N/A" : Model.OrganisationRef)%>
        </div>
        <div class="date">
            <b>Date Lodged:</b>
            <%= Html.Encode(String.Format("{0:g}", Model.DateLodged)) %>
        </div>
        <%if (Model.DateModified != null)
          {%>
        <div class="date">
            <b>Date Modified:</b>
            <%= Html.Encode(String.Format("{0:g}", Model.DateModified))%>
        </div>
        <%} %>
        <div class="main_body">
            <%= Model.Body.Replace(Environment.NewLine, "<br />")%>
        </div>
        <div class="sender">
            <b>Complainant:</b>
            <%= Html.Encode(Model.User.DisplayName) %>
        </div>
        <% if (File.Exists(Model.Proof))
           {%>
        <div class="sender">
            Proof:
            <img alt="Proof" class="proof" src="<%= Url.Action("DisplayImage", new { path = Model.Proof }) %>" />
        </div>
        <% }%>
    </fieldset>
    <% Html.RenderPartial("SettlementDetails", Model.Settlement); %>
    <%if (!Model.IsSettled)
      {%>
    <p>
        <%=Html.ActionLink("Edit", "Edit", new {id = Model.ComplaintID})%>
        |
        <%=Html.ActionLink("Settle", "Settle", new {id = Model.ComplaintID})%>
        <%--| <a href="<%=ViewData["ListURL"].ToString()%>">Back to List</a>--%>
    </p>
    <%}%>
    <button id="addComment" class="formbutton">
        Add a comment</button>
    <div id="commentsContainer">
        <% Html.RenderPartial("CommentGrid", ViewData["Comments"]); %>
    </div>
    <div id="dialog" title="Add a comment">
    </div>
</asp:Content>
